package com.other;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.ValueFilter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by baiguantao on 2017/6/13.
 * 阿里巴巴json  对空值处理
 */
public class JSONUtils {
    private static ValueFilter filter = new ValueFilter() {
        @Override
        public Object process(Object obj, String s, Object v) {
            if(v==null)
                return "";
            return v;
        }
    };
    /**阿里巴巴json*/
    public static void  testOfNull(){
        Map< String , Object > jsonMap = new HashMap< String , Object>();
        jsonMap.put("xyw",1);
        jsonMap.put("123","");
        jsonMap.put("xuyw",null);
        jsonMap.put("xywa","css");
        String jsonString = JSON.toJSONString(jsonMap, filter);
    }


}
